using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using XGameLibrary;
using XGame.GameScreens;
using TomShane.Neoforce.Controls;

namespace XGame
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class XGame : Application
    {
        const int screenWidth = 800;
        const int screenHeight = 600;

        GameScreenManager screenManager;

        public SpriteBatch SpriteBatch;
        public TitleScreen TitleScreen;
        public StartMenuScreen StartMenuScreen;
        public GamePlayScreen GamePlayScreen;
        //public CharacterGeneratorScreen CharacterGeneratorScreen;
        //public LoadGameScreen LoadGameScreen;
        //public SkillScreen SkillScreen;


        public XGame()
        {
            Manager.SkinDirectory = @"Content\Skins\";
            ClearBackground = true;
            BackgroundColor = Color.White;
            ExitConfirmation = false;

            Manager.AutoUnfocus = true;

            Graphics.PreferredBackBufferWidth = screenWidth;
            Graphics.PreferredBackBufferHeight = screenHeight;

            Content.RootDirectory = "Content";
            this.IsMouseVisible = true;

            Components.Add(new InputHandler(this, screenWidth, screenHeight));
            screenManager = new GameScreenManager(this);
            Components.Add(screenManager);

            TitleScreen = new TitleScreen(Manager, screenManager);
            StartMenuScreen = new StartMenuScreen(Manager, screenManager);
            GamePlayScreen = new GamePlayScreen(Manager, screenManager);
            //CharacterGeneratorScreen = new CharacterGeneratorScreen(this, stateManager);
            //LoadGameScreen = new LoadGameScreen(this, stateManager);
            //SkillScreen = new GameScreens.SkillScreen(this, stateManager);
            screenManager.ChangeState(TitleScreen);             

            
        }

        protected override void Initialize()
        {
            base.Initialize();
 
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);
                   

            // TODO: use this.Content to load your game content here
            base.LoadContent();
            
        }


        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (InputHandler.KeyReleased(Keys.Escape) == true)
                this.Exit();

            // TODO: Add your update logic here
            base.Update(gameTime);
        }
    }
}
